<template>
  <ToolbarButton
    icon="i-ri-paint-brush-line"
    title="格式刷"
    @click="applyFormat"
  />
</template>

<script setup lang="ts">
import { inject, type Ref } from 'vue'
import type { Editor } from '@tiptap/vue-3'
import ToolbarButton from "../../../button/index.vue";

defineOptions({
  name: 'FormatBrush'
})

// 注入编辑器实例
const editor = inject<Ref<Editor>>('editor')

// 应用格式
const applyFormat = () => {
  editor?.value?.chain().focus().setFormatPainter(false).run()
}
</script>
